<template>
  <div class="login">
    <h2>登录</h2>
    <div>
    	<p><span>用户名:</span><input v-model = 'userName' placeholder="请输入用户名" /></p>
    	<p><span>密码:</span><input v-model = 'passWord' placeholder="请输入密码" /></p>
    </div>
	<button @click = 'login'>登录</button>
	<button @click = 'back'>返回</button>
   
  </div>
</template>
<script>
	import axios from 'axios'  //引入
	export default{
		name:'login',
		data(){
			return{
				userName:'',
				passWord:''
			}
		},
		methods:{
			login(){
				this.$axios.get('/users/login',{params:{'userName':this.userName,'passWord':this.passWord}}).then(res=>{
					console.log(res);
					alert(res.data.result.msg);
					if(res.data.result.code==200){
						this.$router.push({path: '/goodsList'});
					}
					
				})
			
			},
			back(){
				history.back();
			}
		}
	}
</script>